﻿using Digitalmes.Domain.Entities.Mes.Masters;

namespace Digitalmes.Application.Mes.Masters.Workstations.Queries;

/// <summary>
/// 查询工位命令
/// </summary>
public record GetWorkstationQuery(long LineId) : IRequest<IResult<List<MdWorkstationDto>>>;

internal sealed class GetWorkstationQueryHandler(IRepository<MdWorkstation> repo) : IRequestHandler<GetWorkstationQuery, IResult<List<MdWorkstationDto>>>
{
    public async Task<IResult<List<MdWorkstationDto>>> Handle(GetWorkstationQuery request, CancellationToken cancellationToken)
    {
        var workstations = await repo.GetListAsync(m => m.LineId == request.LineId, cancellationToken);
        return Result.From(workstations.Adapt<List<MdWorkstationDto>>());
    }
}
